package com.div.compiler

import javax.annotation.processing.Filer
import javax.annotation.processing.Messager
import javax.annotation.processing.ProcessingEnvironment
import javax.lang.model.util.Elements
import javax.tools.Diagnostic

abstract class BorrowProcessingEnv(protected var processingEnv: ProcessingEnvironment) {
    protected var messager: Messager? = null

    protected var filer: Filer? = null
    protected var elements: Elements? = null

    init {
        filer = processingEnv.filer
        messager = processingEnv.messager
        elements = processingEnv.elementUtils
    }


    open fun info(msg: String?, vararg args: Any?) {
        messager!!.printMessage(Diagnostic.Kind.NOTE, String.format(msg!!, *args))
    }

    open fun error(msg: String?, vararg args: Any?) {
        messager!!.printMessage(Diagnostic.Kind.ERROR, String.format(msg!!, *args))
    }
}